package com.twu.biblioteca;
import java.util.Scanner;
import java.io.*;

public class BibliotecaApp {

    BookDetails[] bookDetails = new BookDetails[6];
    CustomerDetails[] customerDetails = new CustomerDetails[10];
    MovieDetails[] movieDetails = new MovieDetails[16];

    MemberLogIn memberLogIn = new MemberLogIn();
    MembershipDetails membership_details = new MembershipDetails();
    LibraryData libraryData = new LibraryData();

    int customer_number=0;

    public static void main(String[] args)
    {
        BibliotecaApp bibliotecaApp=new BibliotecaApp();
        bibliotecaApp.getCustomerDetail();
        bibliotecaApp.MenuSelection();
    }

    public static int choice;

    public void getCustomerDetail()
    {
        customerDetails[1] = new CustomerDetails("Pallavi","pallavi@gmail.com","123456","111-1111","pallavi",1,false);
        customerDetails[2] = new CustomerDetails("Sunita","sunita@gmail.com","2345678","222-2222","sunita",2,false);
        customerDetails[3] = new CustomerDetails("Droan","droan@gmail.com","098656262","333-3333","droan",3,false);
        customerDetails[4] = new CustomerDetails("Prince","prince@gmail.com","98738232","444-4444","prince",4,false);
    }

    public void MenuSelection()
    {
        Scanner scanner = new Scanner (System.in);



        System.out.println("\n****WELCOME****");
        System.out.println("1. Home\n2. Books List\n3. Movies\n4. Membership Details\n5. Exit");
        try
        {
            choice = scanner.nextInt();
        }
        catch (Exception E){}
        switch (choice)
        {
            case 1: MenuSelection();
                break;
            case 2: libraryData.BookList(bookDetails);
                System.out.printf("%-20s %-20s %-20s\n","Book","Author","Genre");
                for (int i=1;i<6;++i)
                {
                    System.out.printf("%-20s %-20s %-20s\n", bookDetails[i].bookName,bookDetails[i].author,bookDetails[i].genre);
                }
                    bookSelection();
                    break;
            case 3: libraryData.MovieList(movieDetails);
                    System.out.printf("%-30s %-20s %-25s %-30s\n","Movie","Year","Director","Ratings");
                    for (int i=1;i<16;++i)
                    {
                        System.out.printf("%-30s %-20s %-25s %-30s\n", movieDetails[i].movie_name,movieDetails[i].year_of_release,movieDetails[i].director,movieDetails[i].ratings);
                    }
                    break;
            case 4: System.out.println(customer_number);
                    membership_details.show_membership_details(customer_number, customerDetails);
                    MenuSelection();;
                    break;
            case 5: System.exit(0);
        }
    }

    public void bookSelection()
    {
        System.out.println("\n****Book Selection Menu****");
        System.out.println("1.Reserve\n2.Exit");
        int selection;
        Scanner scanner = new Scanner(System.in);
        selection = scanner.nextInt();
        switch (selection)
        {
            case 1 : customer_number = memberLogIn.checkLogIn(customerDetails);
                     System.out.println("Enter the book number:");
                     int booknum = scanner.nextInt();
                     customerDetails[customer_number].bookReserve(bookDetails[booknum]);
                     MenuSelection();
                     break;
            case 2 : System.exit(0);

        }



    }

}
